//
//  JHMyNewWordsListCell.m
//  JuniRengLish_iOS
//
//  Created by Maiyou on 2019/6/5.
//  Copyright © 2019 revogi. All rights reserved.
//

#import "JHMyNewWordsListCell.h"

@implementation JHMyNewWordsListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setDataDic:(NSDictionary *)dataDic
{
    _dataDic = dataDic;
    
    NSString * word = dataDic[@"word"];
    if ([word containsString:@"\n"])
    {
        NSArray * array = [word componentsSeparatedByString:@"\n"];
        NSString * enTitle = array[0];
        if ([enTitle containsString:@"["])
        {
            NSRange range = [enTitle rangeOfString:@"["];
            enTitle = [enTitle substringToIndex:range.location - 1];
        }
        self.showEnTitle.text = enTitle;
        self.showChTitle.text = array[1];
    }
}

- (IBAction)deleteBtnClick:(id)sender
{
    JHKeyValueStorage * storage = [[JHKeyValueStorage alloc]init];
    [storage removeValueByKey:self.dataDic[@"id"] fromTable:@"NewWords"];
    [DJToast showBottomToast:@"已从生词本删除~"];
    self.DeleteWord();
}


@end
